package com.boat.sample.ddd.api.controller;

import javax.validation.Valid;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.boat.framework.base.api.Response;
import com.boat.sample.ddd.api.dto.FindAccountInfoRsp;
import com.boat.sample.ddd.api.dto.FindUserRsp;
import com.boat.sample.ddd.api.dto.LoginReq;
import com.boat.sample.ddd.api.dto.LoginRsp;
import com.boat.sample.ddd.api.dto.RegisterReq;
import com.boat.sample.ddd.api.dto.RegisterRsp;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "用户接口")
@FeignClient(name = "boat-sample-ddd", contextId = "UserApi")
public interface UserApi {
	@Operation(summary = "用户注册")
	@PostMapping("/api/demo/user/register")
	Response<RegisterRsp> register(@Valid @RequestBody RegisterReq request);
	
	@Operation(summary = "用户登录")
	@PostMapping("/api/demo/user/login")
	Response<LoginRsp> login(@Valid @RequestBody LoginReq request);

	@Operation(summary = "用户信息查询")
	@Parameters(value = {
            @Parameter(name = "userId", required=true, description = "用户id，从1开始", example = "1")
    })
	@GetMapping("/api/demo/user/{userId}")
	Response<FindUserRsp> findUser(@PathVariable(name="userId", required=true) String userId);
	
	@Operation(summary = "用户账户查询")
	@Parameters(value = {
            @Parameter(name = "userId", required=true, description = "用户id，从1开始", example = "1")
    })
	@GetMapping("/api/demo/account/{userId}")
	Response<FindAccountInfoRsp> findAccountInfo(@PathVariable(name="userId", required=true) String userId);
	
}
